n = int(input())
if 1000 <= n <= 9999:
    d = 0
    for i  in range(2, n):
        if n % i ==0:
            d += 1
    if d == 0:
        print(n)
    else:
        print(0)
else:
    print(0)